//
//  NSString+MC_Check.m
//  RetainCount
//
//  Created by liuxiang on 2017/12/4.
//  Copyright © 2017年 liuxiang. All rights reserved.
//

#import "NSString+MC_Check.h"
#import <UIKit/UIKit.h>

@implementation NSString (MC_Check)

+ (BOOL) mc_checkTelNumber:(NSString*)telNumber {
    if ([telNumber stringByReplacingOccurrencesOfString:@" " withString:@""].length != 11) {
        return NO;
    }
    //    电信号段:133/153/180/181/189/177
    //    联通号段:130/131/132/155/156/185/186/145/176
    //    移动号段:134/135/136/137/138/139/150/151/152/157/158/159/182/183/184/187/188/147/178
    //    虚拟运营商:170
    
    NSString *MOBILE = @"^1(3[0-9]|4[57]|5[0-35-9]|8[0-9]|7[06-8])\\d{8}$";
    
    NSPredicate *regextestmobile = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", MOBILE];
    
    return [regextestmobile evaluateWithObject:telNumber];
}

+ (NSString *) mc_stringToIntOrFloat:(NSString *) str {
    CGFloat f = str.floatValue;
    if (f - floorf(f) == 0) {
        return [NSString stringWithFormat:@"%zi",str.integerValue];
    }
    return [NSString stringWithFormat:@"%.2f",str.floatValue];
}

@end
